<%@ page language="java" import="java.util.*,com.hanma.bean.Category" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<%
	Integer pid = (Integer)request.getAttribute("pid");
%>
<body>
<form action="cateaddAction.do" method="post">
	<table border="1" align="center" cellspacing="0" cellpadding="0" width="600">
		<tr align="center" height="50">
			<td colspan="2">分类添加</td>
		</tr>
		<tr align="center" height="50">
			<td>分类名称</td>
			<td><input type="text" name="name"></td>
		</tr>
		<%
			if(pid > 0){
		%>
		
		<tr align="center" height="50">
			<td>所属分类</td>
			<td>
				<select name="pid">
					<option value="0">请选择分类</option>
					<%
					    List<Category> cateList = (List<Category>)request.getAttribute("cateList");
					   	if(cateList != null && cateList.size() > 0){
					   		for(Category category : cateList){		
					 %>
					 <option <%= category.getId()==pid ? "selected" : "" %> value="<%= category.getId()%>"><%= category.getName()%></option>
					 <%
				    		}
				    	}
				     %>
				</select>
			</td>
		</tr>
		<%
			}
		%>
		<tr align="center" height="50">
			<td colspan="2">
			<input type="submit" value="增加">
			</td>
		</tr>
	</table>
</form>
</body>
</html>